home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr49
/
352_01.zip
/
STRPPFNS.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-04-10
|
842b
|
35 lines
// STRPPFNS.CPP - contains String::findstr()
// this module searches one char string for another contained within
// similar to strstr() but obeys String::caseSens
// and returns offset rather than ptr.
//
// NOTE: routine declared static in class {}. No 'this' ptr.
//
#include <stdlib.h>
#include <string.h>
#include <alloc.h>
#include <iostream.h>
#include <ctype.h>
#include "dblib.h"
int String::findstr ( char *a, int na, char *b )
// search for string b in string a. return offset of pattern
{
_NORMALIZE (a, char*);
_NORMALIZE (b, char*);
int nb = strlen (b);
if (! ( a==NULL || b== NULL || nb== 0 ) )
{
int limit = na-nb+1;
for ( int i=0; i<limit; ++i )
{
if ( 0==String::memcmp(a+i, b, nb) ) return i;
}
}
return -1; // not found.
}; // end String::findstr()